<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>182原型继承</title>
</head>

<body>
  <h1>182原型继承</h1>
  <script>
    /*
      1 原型继承
    */
    function Person() {
      this.eyes = 2
      this.mouth = 1
    }

    function Man() {
      this.type = 1
    }
    console.log(new Man())
    Man.prototype = new Person()
    Man.prototype.constructor = Man
    console.log(new Man())

    function Woman() {
      this.type = 0
    }
    console.log(new Woman())
    Woman.prototype = new Person()
    Woman.prototype.constructor = Woman
    console.log(new Woman())
    Woman.prototype.baby = function () {
      console.log('baby')
    }
    console.log(new Woman())
  </script>
</body>

</html>